<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="admin/css/pintuer.css">
<link rel="stylesheet" href="admin/css/admin.css">
<script src="admin/js/jquery.js"></script>
<script src="admin/js/pintuer.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#update_member_form').bind('submit',function(){
		var formData = new FormData();
		var id = $('input[name="id_4"').val();
		var belong = $('input[name="belong_4"').val();
		var title = $('input[name="title_4"]').val();
		var content = $('textarea[name="content_4"]').val();
		var isneturl = $('#selectMemberRank').val();
		var fmResource = $('#selectMemberState').val() == "" ? "1" : $('#selectMemberState').val();
		formData.append('img',$("#url2")[0].files[0]);
		formData.append('id',id);
		formData.append('belong',belong);
		formData.append('title',title);
		formData.append('content',content);
		formData.append('isneturl',isneturl);
		formData.append('fmResource',fmResource);
		$.ajax({
			url:'admin/updateMember.do',
			type:'post',
			data:formData,
			dataType:'html',
			cache: false,  
	        contentType: false,  
	        processData: false,
			success:function(strValue){
				if(strValue.length > 0){
					alert(strValue);
					window.location.href="admin/aboutus_1.do";
				}
			}
		});
		return false;
});
	
	$("#url2").change(function(){
		var objUrl = getObjectURL(this.files[0]) ;
		$("#showhead").attr("src",objUrl);
	});
});
//建立一个可存取到该文件的URL
function getObjectURL(file) {
	var url = null ; 
	if (window.createObjectURL!=undefined) { // basic
		url = window.createObjectURL(file) ;
	} else if (window.URL!=undefined) { // mozilla(firefox)
		url = window.URL.createObjectURL(file) ;
	} else if (window.webkitURL!=undefined) { // webkit or chrome
		url = window.webkitURL.createObjectURL(file) ;
	}
	return url ;
}
window.onload=function(){
	var isneturl = $('input[name="memberRank"]').val();
	var state = $('input[name="memberstate"]').val();
	$("#selectMemberRank option").each(function(){
		var val = $(this).val();
		if(val == isneturl){
			$(this).attr("selected",true);
			return false;
		}
	});
	$("#selectMemberState option").each(function(){
		var val = $(this).val();
		if(val == state){
			$(this).attr("selected",true);
			return false;
		}
	});
	
}
</script>  
</head>
<body>
<div class="panel admin-panel margin-top" id="add">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 修改内容</strong></div>
  <div class="body-content">
    <form method="post" id="update_member_form" class="form-x" enctype="multipart/form-data">   
      <input type="hidden" name="id_4"  value="${member.id }" /> 
      <input type="hidden" name="belong_4"  value="4" /> 
      <div class="form-group">
        <div class="label">
          <label>姓名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w30" name="title_4" value="${member.title }" data-validate="required:请输入姓名" width="30" />         
          <div class="tips"></div>
        </div>
      </div> 
      <div class="form-group">
      <div class="form-group">
        <div class="label">
          <label>成员头像：</label>
        </div>
        <div class="field">
          <input type="file" id="url2" name="file" class="input tips" style="width:25%; float:left;" data-place="right" />
          <div class="tipss">图片尺寸：200*200</div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>头像预览：</label>
        </div>
        <div class="field">
          <img id="showhead" alt="${member.title }" src="${member.resource }" width="357" height="245">
        </div>
      </div>
        <div class="label">
          <label>成员介绍：</label>
        </div>
        <div class="field">
          <textarea class="input" name="content_4" style="height:100px;" >${member.content }</textarea>        
        </div>
      </div>
     <div class="form-group">
          <div class="label">
            <label>成员级别：</label>
          </div>
          <div class="field">
          	<input type="hidden" name="memberRank" value="${member.isneturl }"/>
            <select name="filetype" class="input w50" id="selectMemberRank">
              <option value="">请选择成员级别</option>
              <option value="1">忠勇黄铜</option>
              <option value="2">不屈白银</option>
              <option value="3">荣耀黄金</option>
              <option value="4">华贵铂金</option>
              <option value="5">璀璨钻石</option>
              <option value="6">超凡大师</option>
              <option value="7">最强王者</option>
            </select>
            <div class="tips"></div>
          </div>
        </div>
     <div class="form-group">
          <div class="label">
            <label>成员状态：</label>
          </div>
          <div class="field">
          	<input type="hidden" name="memberstate" value="${member.fmResource }"/>
            <select name="filetype" class="input w50" id="selectMemberState">
              <option value="">请选择成员状态</option>
              <option value="1">上班</option>
              <option value="2">请假</option>
              <option value="3">离职</option>
              
            </select>
            <div class="tips"></div>
          </div>
        </div>
     <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <input type="submit" class="button bg-main icon-check-square-o" value="提交"/>
        </div>
      </div>
    </form>
  </div>
</div>
</body>
</html>